import { useEffect, useState } from "react";
import { useHistory, useParams } from "react-router-dom/cjs/react-router-dom.min"
import FxyhsjglApi from "../../../../../../utils/apis/FxyhsjglApi";
import { Button, Card, Checkbox, Form, Input, Select } from 'antd';

export default function FxyhLook() {
    const [dynamicForms, setDynamicForms] = useState();
    const [idDatas, setIdDatas] = useState();
    const [componentDisabled, setComponentDisabled] = useState(true);
    const [form] = Form.useForm();
    const history = useHistory();
    const id = useParams()?.id
    const [params, setParams] = useState({
        pageSize: 10,
        pageNum: 1
    })

    useEffect(() => {
        FxyhsjglApi.fxyhEditDynamicApi().then(datas => {
            setDynamicForms(datas)
        })
    }, [])
    useEffect(() => {
        if (params) {
            FxyhsjglApi.listId(id).then(resp => {

                setIdDatas(resp.data)
                console.log(resp.data)
                form.setFieldsValue({
                    ...resp.data,

                })
            })
        }
    }, [id, form, params])

    const quxiaoHandle = () => {
        history.push(`/manager/fxyhsjgl`)
    }
    //保存

    return <div className='layout-h h100' style={{
        overflow: "scroll"
    }}>
        {/* <Card className='h100 fill w0' style={{
          position: "relative",
        }} >
          <BusinessMap />
    
        </Card> */}
        <Card className='h100 fill' style={{
            height: "1500px"
        }}>
            <Form method="post"

                form={form}>
                <header style={{
                    fontSize: 20,
                    fontWeight: "bold"
                }}>隐患数据查看</header>
                <hr />

                <div className="InputForm" style={{
                    display: "flex",
                    flexWrap: "wrap"
                }}>
                    {idDatas !== undefined && dynamicForms !== undefined && dynamicForms.map((formItem) => {
                        let node;
                        switch (formItem.type) {
                            case 'select':
                                node = <Select></Select>;
                                break;
                            case 'text':
                            default:
                                node = <Input

                                    disabled={componentDisabled}
                                    style={{
                                        width: '90%',
                                        fontSize: '15px',
                                        color:'#ffffff',
                                        fontWeight: 'bold',
                                        // backgroundColor:'transparent',
                                        // opacity:'0.5'

                                    }}
                                    onChange={(e) => {

                                    }}

                                />
                        }

                        return <div style={{
                            flexBasis: "33%",
                            marginBottom: "10px"
                        }}><Form.Item
                            label={formItem.alias}
                            name={formItem.name}

                            //   disabled={componentDisabled}
                            rules={[
                                {
                                    //   required: true,
                                    disable: true

                                }
                            ]}

                        >
                                {node}
                            </Form.Item></div>
                    })}

                </div>



                <div className="btn-bottom" style={{
                    //   marginLeft:'240px'
                }}>
                    {/* <Button type="primary"

                    >上一条</Button>
                    <Button type="primary"

                    >下一条</Button> */}
                    <Button onClick={quxiaoHandle}>返回</Button>
                </div>
            </Form>
        </Card>


    </div>
}